package abstractEntities;

import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import entities.Lesson;
import entities.Student;
import entitiesIds.LessonstudentId;

/**
 * AbstractLessonstudent entity provides the base persistence definition of the
 * Lessonstudent entity. @author MyEclipse Persistence Tools
 */
@MappedSuperclass
public abstract class AbstractLessonstudent implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = -5099528541708533220L;
	private LessonstudentId id;
	private Lesson lesson;
	private Student student;
	private Date finishDate;

	// Constructors

	/** default constructor */
	public AbstractLessonstudent() {
	}

	/** minimal constructor */
	public AbstractLessonstudent(LessonstudentId id, Lesson lesson,
			Student student) {
		this.id = id;
		this.lesson = lesson;
		this.student = student;
	}

	/** full constructor */
	public AbstractLessonstudent(LessonstudentId id, Lesson lesson,
			Student student, Date finishDate) {
		this.id = id;
		this.lesson = lesson;
		this.student = student;
		this.finishDate = finishDate;
	}

	// Property accessors
	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "idStudent", column = @Column(name = "idStudent", nullable = false)),
			@AttributeOverride(name = "idLesson", column = @Column(name = "idLesson", nullable = false)) })
	public LessonstudentId getId() {
		return this.id;
	}

	public void setId(LessonstudentId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idLesson", nullable = false, insertable = false, updatable = false)
	public Lesson getLesson() {
		return this.lesson;
	}

	public void setLesson(Lesson lesson) {
		this.lesson = lesson;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idStudent", nullable = false, insertable = false, updatable = false)
	public Student getStudent() {
		return this.student;
	}

	public void setStudent(Student student) {
		this.student = student;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "finishDate", length = 10)
	public Date getFinishDate() {
		return this.finishDate;
	}

	public void setFinishDate(Date finishDate) {
		this.finishDate = finishDate;
	}

}